"""
讯录文件contacts.txt中存在若干联系人的信息
每个联系人的信息由姓名和电话号码组成，
编写程序完成以下功能：输入姓名
若通讯录中存在，则将联系人信息输出；
若不存在，则输出“Not Found”
Zhang, 2301
Zhao,2302
Li,2304
Sun,2305
"""

file = open("contacts.txt", "r", encoding="UTF-8")
dict_tmp = {}
for line in file.readlines():
    line = line.strip()
    k = line.split(',')[0]
    v = line.split(',')[1]
    dict_tmp[k] = v

dic = dict_tmp
print(dic)
name = input("输入名字")
justice = False
for key in dic:
    if key == name:
        print(f"{key},{dic[name]}")
        justice = True
if justice == False:
    print("Not Found")
